<?php
namespace app\admin\api;

use think\Controller;
use \think\Session;
use app\admin\common\Http\ConferenceHttpClient;

//论文摘要管理接口类
class ConferencePaperAbstract extends ConferenceHttpClient
{

    /**
     * 获取会议站论文摘要管理列表
     * @return [type] [description]
     */
    public function abstractList($token,$paper_id,$data)
    {
        //获取数据
        $url = '/v1/site/paper/'.$paper_id.'/abstracts';

        $res['page'] = $data['page'];
        $res['page_size'] = $data['limit'];

        //获取当前论文id存入session
        Session::set('paper_id',$paper_id);

        //设置headers头
        $headers = getheader($token);

        //请求接口信息
        $result = $this->get($url,$res,$headers);

        if ($result->code == 0){
            return $result->data;

        }else{
            return $result->message;
        }
    }


    /**
     * 会议站论文摘要管理创建
     * @return [type] [description]
     */
    public function abstractCreate($data,$token)
    {
        $paper_id = Session::get('paper_id');

        $url = '/v1/site/paper/'.$paper_id.'/abstracts';

        //设置headers头
        $headers = getheader($token);

        //请求接口信息
        $result = $this->post($url,$data,$headers);

        if ($result->code == 0){
            return 555;

        }else{
            return $result->message;
        }

    }


    /**
     * 获取会议站论文摘要管理详情
     * @return [type] [description]
     */
    public function abstractDetails($abstract_id,$token)
    {
        $paper_id = Session::get('paper_id');
        //获取数据
        $url = '/v1/site/paper/'.$paper_id.'/abstracts/'.$abstract_id;

        //设置headers头
        $headers = getheader($token);

        $res = array();
        //$res['id'] = $id;
        //请求接口信息
        $result = $this->get($url,$res,$headers);

        if ($result->code == 0){
            return $result->data->item;
        }else{
            return $result->message;
        }

    }


    /**
     * 会议站论文管理更新
     * @return [type] [description]
     */
    public function abstractUpdate($abstract_id,$data,$token)
    {
        if($data) {

            $paper_id = Session::get('paper_id');

            //获取数据
            $url = '/v1/site/paper/'.$paper_id.'/abstracts/'.$abstract_id;

            //设置headers头
            $headers = getheader($token);

            //请求接口信息
            $result = $this->put($url,$data,$headers);

            if ($result->code == 0){
                return 555;
            }else{
                return $result->message;
            }
        }

    }


    /**
     * 会议站论文管理删除
     * @return [type] [description]
     */
    public function abstractDelete($abstract_id,$token)
    {
        $paper_id = Session::get('paper_id');

        //获取数据
        $url = '/v1/site/paper/'.$paper_id.'/abstracts/'.$abstract_id;

        //设置headers头
        $headers = getheader($token);

        $res = array();
        //$res['id'] = $id;
        //请求接口信息
        $result = $this->delete($url,$res,$headers);

        if ($result->code == 0){
            return 555;
        }else{
            return $result->message;
        }
    }


    /**
     * 会议站论文摘要状态管理--审核中
     * @return [type] [description]
     */
    public function abstractreview($abstract_id,$token)
    {
        $paper_id = Session::get('paper_id');

        //获取数据
        $url = '/v1/site/paper/'.$paper_id.'/abstracts/'.$abstract_id.'/review';

        //设置headers头
        $headers = getheader($token);

        $res = array();
        //$res['id'] = $id;
        //请求接口信息
        $result = $this->get($url,$res,$headers);

        if ($result->code == 0){
            return 555;
        }else{
            return $result->message;
        }
    }

    /**
     * 会议站论文摘要状态管理--审核通过
     * @return [type] [description]
     */
    public function abstractpassed($abstract_id,$token)
    {
        $paper_id = Session::get('paper_id');

        //获取数据
        $url = '/v1/site/paper/'.$paper_id.'/abstracts/'.$abstract_id.'/passed';

        //设置headers头
        $headers = getheader($token);

        $res = array();
        //$res['id'] = $id;
        //请求接口信息
        $result = $this->get($url,$res,$headers);

        if ($result->code == 0){
            return 555;
        }else{
            return $result->message;
        }
    }


    /**
     * 会议站论文摘要状态管理--审核拒绝
     * @return [type] [description]
     */
    public function abstractrefuse($abstract_id,$token)
    {
        $paper_id = Session::get('paper_id');

        //获取数据
        $url = '/v1/site/paper/'.$paper_id.'/abstracts/'.$abstract_id.'/refuse';

        //设置headers头
        $headers = getheader($token);

        $res = array();
        //$res['id'] = $id;
        //请求接口信息
        $result = $this->get($url,$res,$headers);

        if ($result->code == 0){
            return 555;
        }else{
            return $result->message;
        }
    }


    /**
     * 会议站论文摘要状态管理--审核修订
     * @return [type] [description]
     */
    public function abstractrevise($abstract_id,$token)
    {
        $paper_id = Session::get('paper_id');

        //获取数据
        $url = '/v1/site/paper/'.$paper_id.'/abstracts/'.$abstract_id.'/revise';

        //设置headers头
        $headers = getheader($token);

        $res = array();
        //$res['id'] = $id;
        //请求接口信息
        $result = $this->get($url,$res,$headers);

        if ($result->code == 0){
            return 555;
        }else{
            return $result->message;
        }
    }

}